﻿@model IEnumerable<Ecommerce.Areas.Manager.Models.Product>
@{
    ViewBag.Title = "Your cart";
}

<div id="detailProd" style="margin-right: 30px;">
    @if (Model.Count() == 0)
    {
        <p>Your cart is empty</p>
    }
    else
    {
        <div class="header" style="width: 100%; float: right">

            @Html.ActionLink("Process to check out", "Index", "Checkout", null, new { @class = "button checkout", style = "float: right" })
            @Html.ActionLink("Continue shopping", "Index", "Template", null, new { @class = "button checkout", style = "float: right;" })
        </div>

        <table>
            <thead>
                <tr>
                    <td>#</td>
                    <td>Product Name</td>
                    <td>Category Name</td>
                    <td>Price</td>
                    <td>Action</td>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Select((model, index) => new { index, model }))
                {
                    <tr>
                        <td>1</td>
                        <td>@Html.ActionLink(@item.model.ProdName, "Detail", "Template", new { prodID = item.model.ProductID }, null) </td>
                        <td>@item.model.Category.CategoryName</td>
                        <td>@item.model.Price</td>
                        <td>@Html.ActionLink("Remove", "Remove", new { prodID = item.index })</td>
                    </tr>
                }
                <tr>
                    <td colspan="3"></td>
                    <td><b>Total : @Model.Sum(model => model.Price)$</b></td>
                    <td></td>
                </tr>
            </tbody>
        </table>
        <div class="header" style="width: 100%; float: right; margin-top: 20px;">
            @Html.ActionLink("Process to check out", "Index", "Checkout", null, new { @class = "button checkout", style = "float: right" })
            @Html.ActionLink("Continue shopping", "Index", "Template", null, new { @class = "button checkout", style = "float: right;" })
        </div>
    }
</div>

